home *** CD-ROM | disk | FTP | other *** search
/ SGI Desktop Special Edition 1.1 / SGI Desktop Special Edition 1.1.iso / dist / mmail.idb / usr / lib / Zmail / convert.mh.z / convert.mh
Encoding:
Text File  |  1995-11-13  |  1.4 KB  |  66 lines

  1. # Functions to convert an MH folder to Z-Mail.  Usage from within Z-Mail:
  2. #    convert_mh folder
  3. # where "folder" is a directory (MH-style folder).
  4. #
  5.  
  6. function isdir() {
  7.     if -e $1/.
  8.     return 0
  9.     else
  10.     return -1
  11.     endif
  12. }
  13.  
  14. function mh_message() {
  15.     sh "(echo ''; echo '--------'; echo '') >> $2"
  16.     sh cat $1 >> $2
  17. }
  18.  
  19. function convert_mh() {
  20.     if X$1 == X
  21.     error Specify MH folder directory.
  22.     return -1
  23.     endif
  24.     isdir $1
  25.     if $status != 0
  26.     error $1 not a directory
  27.     return -1
  28.     endif
  29.     open $1
  30. # The following is necessary in Z-Mail 2.0.5 and earlier.  If the "open"
  31. # (above) fails with an "is a directory" error, try this instead.
  32. #   set tmpfolder = /tmp/mh$$
  33. #   sh "echo From $user `date` > $tmpfolder"
  34. #   foreach f ($1/[0-9]*) 'mh_message $f $tmpfolder'
  35. #   open $tmpfolder | undigest -m
  36. #   if $status != 0
  37. #    return -1
  38. #   endif
  39. #   delete 1,2
  40. }
  41.  
  42. function ask_convert_mh() {
  43.     ask -file filename "What MH folder do you want to convert?"
  44.     if $status == -1
  45.     return -1;
  46.     endif
  47.     convert_mh $filename
  48.     if $status == 0
  49.     ask "MH folder converted.\nDo you want to remove $filename now?"
  50.     if $status == 0
  51.         sh rm -fr $filename
  52.     endif
  53.     if $status == -1
  54.         return -1
  55.     endif
  56.     set realfile = $filename:t
  57.      copy * {`:d`} $folder/$realfile
  58.     delete *
  59. # If you use the Z-Mail 2.0.5 version of convert_mh, remove "-n" below.
  60.     folder -n $folder/$realfile
  61.     unset realfile
  62.     endif
  63. }
  64.  
  65. Button Convert-MH ask_convert_mh
  66.